﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;

namespace YXShop.TemplateAction
{
    public partial class LabelParse
    {
        /// <summary>
        /// FS:LabelType=SystemParameter标签处理函数
        /// </summary>
        /// <returns></returns>
        public string HeadOrBottomInfo()
        {
            string reStr = string.Empty;
            string mystyle = this.Label_Inserted;
            string str_Class = this.GetParamValue("YX:Class");
            YXShop.Common.SysParameter sp = new YXShop.Common.SysParameter();
            if (str_Class == "Head")
            {
                if (mystyle.IndexOf("[#SetAsDefault]") > -1)
                {
                    string str = "<span style=\"CURSOR: hand\" onclick=\"var strHref=window.location.href;this.style.behavior='url(#default#homepage)';this.setHomePage('" + sp.SiteHttp + "');\">设为首页</span>";
                    mystyle = mystyle.Replace("[#SetAsDefault]", str);
                }
                if (mystyle.IndexOf("[#AddToMyFavorite]") > -1)
                {
                    string str = "<span title=\"" + sp.WebSiteName + "\" style=\"CURSOR: hand\" onclick=\"javascript:window.external.addFavorite(''+window.location.href+'','" + sp.WebSiteName + "')\">加入收藏</span>";
                    mystyle = mystyle.Replace("[#AddToMyFavorite]", str);
                }
                if (mystyle.IndexOf("[#Logo]") > -1)
                {
                    string str = "<a href='" + sp.DummyPaht + "default.aspx'><img src='" + sp.DummyPaht + sp.WebSiteLogo + "' border='0'></a>";
                    mystyle = mystyle.Replace("[#Logo]", str);
                }
                if (mystyle.IndexOf("[#Banner]") > -1)
                {
                    string str = "<img src='" + sp.DummyPaht + sp.WebSiteBrannd + "' border='0'/>";
                    mystyle = mystyle.Replace("[#Banner]", str);
                }
                if (mystyle.IndexOf("[#LoginAndReg]") > -1)//登录与注册
                {
                    string str = "";
                    if (HttpContext.Current.Session["MemberName"] != null)
                    {
                        string ExitURL = Common.UrlStr("exitmembercenter", "", "membercenter/");
                        str = "【<a href='" + ExitURL + "'>退出管理</a>】";
                    }
                    else
                    {
                        string LogingURL = Common.UrlStr("login", "", "membercenter/");
                        str += " <a href=\"" + LogingURL + "\">[登录]</a>";
                        if (sp.IsRegistered)
                        {
                            string RegURL = Common.UrlStr("registered", "", "membercenter/");
                            str += "&nbsp;&nbsp;<a href='" + RegURL + "'>[免费注册]</a>";
                        }
                    }
                    mystyle = mystyle.Replace("[#LoginAndReg]", str);
                }
                if (mystyle.IndexOf("[#ShopCatchline]") > -1)//商城标语
                {
                    string str = "";
                    if (HttpContext.Current.Session["MemberName"] != null)
                    {
                        string ExitURL = Common.UrlStr("exitmembercenter", "", "membercenter/");
                        str = "您好，<label style='color:red'>" + HttpContext.Current.Session["MemberName"].ToString() + "</label>欢迎您回来！";
                    }
                    else
                    {
                        string LogingURL = Common.UrlStr("login", "", "membercenter/");
                        str += "您好，欢迎光临！开始购物之旅。";
                    }

                    mystyle = mystyle.Replace("[#ShopCatchline]", str);
                }
            }
            else if (str_Class == "Bottom")
            {
                if (mystyle.IndexOf("[#WebSiteTel]") > -1)
                {
                    mystyle = mystyle.Replace("[#WebSiteTel]", sp.SiteTel);
                }
                if (mystyle.IndexOf("[#WebSiteFax]") > -1)
                {
                    mystyle = mystyle.Replace("[#WebSiteFax]", sp.SiteFax);
                }
                if (mystyle.IndexOf("[#SiteEmail]") > -1)
                {
                    mystyle = mystyle.Replace("[#SiteEmail]", sp.SiteEmail);
                }
                if (mystyle.IndexOf("[#Copyright]") > -1)
                {
                    mystyle = mystyle.Replace("[#Copyright]", sp.Copyright);
                }
                if (mystyle.IndexOf("[#Versions]") > -1)
                {
                    mystyle = mystyle.Replace("[#Versions]", sp.Versions);
                }
                if (mystyle.Contains("[#StatisticalCode]"))
                {
                    mystyle = mystyle.Replace("[#StatisticalCode]", sp.StatisticalCode);
                }
            }
            reStr=Template.ReplaceLabels(mystyle);
            return Template.ReplaceLabels(reStr);
        }
    }
}
